const http = require('http');
const queryString = require('querystring');

const server = http.createServer(((req, res) => {
    console.log('method:' , req.method); // GET
    const url = req.url;
    console.log('url:' , url);
    /*解析querystring*/
    req.query = queryString.parse(url.split("?")[1]);
    console.log('query:' , req.query);
    /*将querystring返回*/
    res.end(JSON.stringify(req.query));
}));
server.listen(8000);
console.log('ok');